package com.studentportalen;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class CoursesDetailsActivity extends Activity {

	private int _id = -1;
	private Course c = null;
	//TextViews
	TextView course;
	TextView prerequisites;
	TextView purpose;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_courses_details);
        
        //Get data from intent
        Bundle extras = getIntent().getExtras();
        if(extras != null){
        	_id = extras.getInt("id");
        }
        
        DBHelper db = Global.getDBHelper();
        c = db.getCourse(_id);
        
        course = (TextView) findViewById(R.id.txt_course_text);
        prerequisites  = (TextView) findViewById(R.id.txt_prerequisites_text);
        purpose  = (TextView) findViewById(R.id.txt_purpose_text);
        
        course.setText(c.getName());
        prerequisites.setText(c.getPrerequisites());
        purpose.setText(c.getPurpose());
        
    }
    
    public void openHomepage(View view){
    	Uri uri = Uri.parse(c.getHomepage());
    	Intent myIntent = new Intent(Intent.ACTION_VIEW, uri);
    	startActivity(myIntent);
    }
}
